#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include <func.h>
#include "taskQueue.h"
#include "mandate.h"
#include "timeout_exit.h"
#include <l8w8jwt/encode.h>
#include <l8w8jwt/decode.h>
#define MAXCMD 64
#define MAXCMDARGV 256
#define MAXUSRNAME 64
#define MAXSESSIONID 256
#define NETDISK_LOG_INFO(user, cmd, arg)              \
    do                                                \
    {                                                 \
        syslog(LOG_INFO, "%s %s %s", user, cmd, arg); \
    } while (0);

#define NETDISK_LOG_DEBUG \
    while (0)             \
    {                     \
    }
typedef struct threadPool_s
{
    pthread_t *tidArr;
    int workerNum;
    taskQueue_t taskQueue;
    int exitflag;
    char cmd[MAXCMD];
    char cmd_argv[MAXCMDARGV];
} threadPool_t;
typedef struct train_s
{
    int length;
    char data[1000];
} train_t;
typedef struct client_info_s{
     int cur_id;
     char username[64];
}client_info_t;
int initThreadPool(threadPool_t *threadPool, int workerNum);
int makeWorker(threadPool_t *threadPool);
void *threadFunc(void *arg);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);
int tcpInit(const char *ip, const char *port, int *psockfd);
int transfile(int netfd, char *filename);
int recvn(int netfd, void *buf, int length);
int recv_msg(int netfd, char *buf);
int send_msg(int netfd, char *buf);
int recvfile(int netfd);
int getsfile(int netfd, char *filename);

// 第四期 长短命令分离

int users_login(threadPool_t *threadPool, int netfd, client_info_t *user_table);

int cmd_execute(threadPool_t *threadPool, int netfd, int sockfd,client_info_t *user_table);

int token_genarate(char* username,char* token);
int token_check(char* username,char* token);
#endif
